<?php


namespace app\api\controller;

use think\Controller;
use think\Db;
use think\Log;
use think\Request;

class OrderFeedback extends Controller
{
    
    public function __construct()
    {
        header('Content-Type: text/html;charset=utf-8');
        header('Access-Control-Allow-Origin:*'); // *代表允许任何网址请求
        header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'); // 允许请求的类型
        header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
        header('Access-Control-Allow-Headers: Content-Type,Content-Length,Accept-Encoding,X-Requested-with, Origin'); // 

    }

    public function info(){
        $params = Request::instance()->param();
        if(empty($params['order_id'])){
            exit(json_encode(['code'=>400,'msg'=>'缺少参数order_id']));
        }
        $res = db('tradelog','db_config2')->where(['id'=>$params['order_id']])->find();
        if(empty($res)){
            exit(json_encode(['code'=>400,'msg'=>'未找到订单']));
        }
        db('tradelog','db_config2')->where(['id'=>$params['order_id']])->update([
            'feedback_type'=>$params['feedback_type'],
            'feedback_info'=>$params['feedback_info'],
        ]);
        exit(json_encode(['code'=>200,'msg'=>'']));
    }
    
}

